Skip to content

Enable preview deployments and PR comments in docs-preview-local#3297

Closed
itsalexcm wants to merge 2 commits into
mainfrom
fix/enable-isolated-docs-preview
Closed

Enable preview deployments and PR comments in docs-preview-local#3297
itsalexcm wants to merge 2 commits into
mainfrom
fix/enable-isolated-docs-preview

Conversation

@itsalexcm
Copy link
Copy Markdown
Contributor

Enable GitHub deployments (were gated off), grant deployments:write, and post a bot comment with the handbook preview base URL plus links to changed Markdown pages when the local docs build succeeds.

Enable GitHub deployments (were gated off), grant deployments:write, and
post a bot comment with the handbook preview base URL plus links to
changed Markdown pages when the local docs build succeeds.

Co-authored-by: Cursor <cursoragent@cursor.com>
@itsalexcm itsalexcm requested a review from a team as a code owner May 11, 2026 15:55
@itsalexcm itsalexcm requested a review from cotti May 11, 2026 15:55
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 11, 2026

Review Change Stack

Warning

Rate limit exceeded

@itsalexcm has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 12 minutes and 49 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: da88787f-82a8-4b9d-8cd6-e0512c594681

📥 Commits

Reviewing files that changed from the base of the PR and between 9095b01 and 984c325.

📒 Files selected for processing (1)
  • tests-integration/Elastic.Documentation.Api.IntegrationTests/OtlpProxyIntegrationTests.cs
📝 Walkthrough

Walkthrough

This workflow update activates the docs-preview GitHub Deployment and adds automatic PR commenting. The build job permissions now grant deployments: write access. Previously hard-disabled "Create Deployment" and "Update deployment status" steps are re-enabled, conditionally running when the branch matches and required outputs exist. A new comment job posts a PR comment listing up to 15 changed Markdown files with links to their local preview URLs under the computed path prefix.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and specifically summarizes the main changes: enabling preview deployments and adding PR comments to the docs-preview-local workflow.
Description check ✅ Passed The description is directly related to the changeset, clearly explaining the three key changes: enabling GitHub deployments, granting deployments:write permission, and posting bot comments with preview links.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch fix/enable-isolated-docs-preview

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.github/workflows/docs-preview-local.yml (1)

195-198: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Gate PR comments on actual preview publish success.

Lines 385-387 only require needs.build.result == 'success'. The build job can still be “success” when docs build/upload were skipped, so this job may post dead preview links.

Proposed fix
  build:
    outputs:
      deployment_result: ${{ steps.deployment.outputs.result }}
      path_prefix: ${{ steps.generate-path-prefix.outputs.result }}
+     preview_published: ${{ steps.s3-upload.outcome == 'success' }}

  comment:
    if: >
      github.event_name == 'pull_request'
      && needs.check.outputs.any_modified == 'true'
      && needs.build.outputs.path_prefix != ''
-     && needs.build.result == 'success'
+     && needs.build.outputs.preview_published == 'true'

Also applies to: 382-387

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/docs-preview-local.yml around lines 195 - 198, The job's
gating condition currently checks only needs.build.result == 'success', which
can be true even when docs publish was skipped; update the job 'if' condition to
also require the deployment output to indicate a real preview was published by
adding a check for needs.build.outputs.deployment_result == 'success' (i.e.
require both needs.build.result == 'success' &&
needs.build.outputs.deployment_result == 'success'), and apply the same change
where the condition appears (referencing needs.build.result and
needs.build.outputs.deployment_result and the outputs
deployment_result/path_prefix from steps.deployment and
steps.generate-path-prefix).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/docs-preview-local.yml:
- Around line 434-442: Replace the single-page listComments call with a full
pagination call and tighten the bot identity check: use
github.paginate(github.rest.issues.listComments, { owner, repo, issue_number })
to retrieve all comment pages into comments, then find existing by matching
c.user.login === 'github-actions[bot]' && c.body.startsWith(title) (instead of
c.user.type) so you won't miss existing comments on busy PRs or accidentally
match other bots.

---

Outside diff comments:
In @.github/workflows/docs-preview-local.yml:
- Around line 195-198: The job's gating condition currently checks only
needs.build.result == 'success', which can be true even when docs publish was
skipped; update the job 'if' condition to also require the deployment output to
indicate a real preview was published by adding a check for
needs.build.outputs.deployment_result == 'success' (i.e. require both
needs.build.result == 'success' && needs.build.outputs.deployment_result ==
'success'), and apply the same change where the condition appears (referencing
needs.build.result and needs.build.outputs.deployment_result and the outputs
deployment_result/path_prefix from steps.deployment and
steps.generate-path-prefix).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: a6bbf2fa-f30b-43f3-a5f6-eb1155dd1543

📥 Commits

Reviewing files that changed from the base of the PR and between ef78eec and 9095b01.

📒 Files selected for processing (1)
  • .github/workflows/docs-preview-local.yml

Comment on lines +434 to +442
const { data: comments } = await github.rest.issues.listComments({
owner,
repo,
issue_number,
})
const existing = comments.find(
(c) =>
c.user.type === 'Bot' && c.body.startsWith(title)
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

cat .github/workflows/docs-preview-local.yml | wc -l

Repository: elastic/docs-builder

Length of output: 68


🏁 Script executed:

sed -n '420,460p' .github/workflows/docs-preview-local.yml

Repository: elastic/docs-builder

Length of output: 1297


🏁 Script executed:

# Search for context around the comment upsert logic
sed -n '400,480p' .github/workflows/docs-preview-local.yml

Repository: elastic/docs-builder

Length of output: 2169


🌐 Web query:

GitHub Actions @actions/github paginate listComments API documentation

💡 Result:

@actions/github “paginate” for listComments: use Octokit pagination (Link-header driven) on the REST endpoint that lists issue comments (issues/{issue_number}/comments). The REST endpoint supports pagination via the page and per_page query parameters (max 100) and also supports since filtering; GitHub paginates results using the response Link header when there are more results. [1][2][3] In GitHub Actions, the @actions/github package provides a hydrated Octokit client (github.getOctokit / octokit.rest.*). [4] Use octokit.paginate with the list-comments endpoint so it automatically fetches all pages until the last page, returning a single array of items. [2][3] Example (actions/github-script / Node JS): const comments = await github.paginate(github.rest.issues.listComments, { owner: context.repo.owner, repo: context.repo.repo, issue_number: 123, per_page: 100, }); This pattern is also used in the official actions/github-script discussion as the fix when listComments exceeds the single-page default of 30. [5] Key REST details for listComments / issue comments: - Endpoint: GET /repos/{owner}/{repo}/issues/{issue_number}/comments [1] - Pagination query parameters: page (default 1), per_page (default 30, max 100) [1] Octokit pagination mechanics: - GitHub Docs’ pagination guide states that Octokit’s paginate fetches next pages until the last page and returns all items as a single array. [3]

Citations:


🌐 Web query:

@actions/github github.paginate method documentation

💡 Result:

In GitHub Actions, @actions/github exposes an authenticated Octokit client and supports pagination via octokit.paginate (and related iterator helpers) when using the underlying Octokit REST pagination plugin. What documentation exists for github.paginate / octokit.paginate 1) Official GitHub REST API pagination docs (Octokit integration) GitHub documents that for paginated REST API results you can use octokit.paginate, which fetches the next page until the last page and returns all items as a single array; it also supports a map function and octokit.paginate.iterator to iterate page-by-page. [1][2] 2) Authoritative Octokit plugin documentation: @octokit/plugin-paginate-rest The plugin-paginate-rest package documentation states that it adds octokit.paginate which accepts the same parameters as octokit.request; it wraps octokit.request and continues requesting while there is a rel="next" link in the response Link header. It also notes only “List...” endpoints are supported for pagination and that non-list endpoints behave like octokit.request. [3] What the method does (high-confidence behavior) - octokit.paginate wraps octokit.request and keeps requesting the “next” URL as long as the response Link header contains rel="next". [3] - It returns all fetched items as a single array (even when the underlying raw REST result was an object, octokit.paginate returns an array of items). [1][2] - You can supply a map function to process each page’s results and optionally end early by calling done. [1] - Alternatively, octokit.paginate.iterator lets you iterate one page/response at a time, more memory-efficient than collecting everything. [1] How this maps to @actions/github - @actions/github is a hydrated Octokit client returned by getOctokit(token). [4][5] - As part of the standard usage, the client retains pagination APIs (github.paginate) consistent with Octokit.js (used in github-script examples). For example, actions/github-script shows calling await github.paginate(opts) to get all pages of a REST list endpoint. [6] Practical example pattern (from official docs) - For REST: use octokit.paginate with the REST “list” endpoint route/params, and optionally map. GitHub’s docs explicitly recommend octokit.paginate for fetching paginated results via Octokit.js. [1] If you meant pagination for GraphQL - There is a separate plugin for GraphQL pagination: octokit.graphql.paginate, which paginates by scanning for pageInfo and using endCursor when hasNextPage is true. [7] Most relevant references to read - GitHub Docs: “Using pagination in the REST API” (Octokit.paginate + iterator + map function). [1][2] - Octokit plugin: @octokit/plugin-paginate-rest.js (how octokit.paginate is implemented via Link header rel="next"). [3] - @actions/github package overview (shows it returns an authenticated Octokit client and is how Actions code gets an Octokit instance). [4][5]

Citations:


Fetch all comment pages to avoid duplicates and strict bot identity match.

This only fetches the first page (~30 comments) and matches any bot. On busy PRs, it misses the existing comment, creating duplicates. Use github.paginate() to fetch all pages and match specifically against github-actions[bot] to avoid accidentally updating other bots' comments.

Proposed fix
-            const { data: comments } = await github.rest.issues.listComments({
-              owner,
-              repo,
-              issue_number,
-            })
+            const comments = await github.paginate(
+              github.rest.issues.listComments,
+              { owner, repo, issue_number, per_page: 100 }
+            )
             const existing = comments.find(
               (c) =>
-                c.user.type === 'Bot' && c.body.startsWith(title)
+                c.user?.login === 'github-actions[bot]' &&
+                c.body?.startsWith(title)
             )
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/docs-preview-local.yml around lines 434 - 442, Replace the
single-page listComments call with a full pagination call and tighten the bot
identity check: use github.paginate(github.rest.issues.listComments, { owner,
repo, issue_number }) to retrieve all comment pages into comments, then find
existing by matching c.user.login === 'github-actions[bot]' &&
c.body.startsWith(title) (instead of c.user.type) so you won't miss existing
comments on busy PRs or accidentally match other bots.

@itsalexcm itsalexcm added the ci label May 11, 2026
Wire OTEL_EXPORTER_OTLP_ENDPOINT via WebApplicationFactory settings so
mapOtlpEndpoints runs consistently under parallel CI.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions
Copy link
Copy Markdown

Docs preview (local build)

Handbook preview: https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/3297/

@itsalexcm itsalexcm closed this May 11, 2026
@itsalexcm itsalexcm deleted the fix/enable-isolated-docs-preview branch May 11, 2026 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant